package top.dj.entity;

/**
 * @Author: DengJia
 * @Date: 2021/9/9 10:35
 * @Description:
 */

//@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
public class FileInfo {
    private final String id; // required
    private final String fileName; // optional
    private final Long fileSize; // optional
    private final String fileType; // optional
    private final String filePath; // optional

    // 私有构造器，对象的创建依赖于Builder
    private FileInfo(Builder builder) {
        this.id = builder.id;
        this.fileName = builder.fileName;
        this.fileSize = builder.fileSize;
        this.fileType = builder.fileType;
        this.filePath = builder.filePath;
    }

    public String getId() {
        return id;
    }

    public String getFileName() {
        return fileName;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public String getFileType() {
        return fileType;
    }

    public String getFilePath() {
        return filePath;
    }

    public static class Builder {
        private final String id; // required，使用final修饰
        private String fileName;
        private Long fileSize;
        private String fileType;
        private String filePath;

        public Builder(String id) {
            this.id = id;
        }

        /* 返回Builder本身对象，链式调用。 */

        public Builder fileName(String fileName) {
            this.fileName = fileName;
            return this;
        }

        public Builder fileSize(Long fileSize) {
            this.fileSize = fileSize;
            return this;
        }

        public Builder fileType(String fileType) {
            this.fileType = fileType;
            return this;
        }

        public Builder filePath(String filePath) {
            this.filePath = filePath;
            return this;
        }

        // 通过Builder构建所需要的实体对象，并且每次都产生新的实体对象。
        public FileInfo build() {
            return new FileInfo(this);
        }
    }
}
